package NC;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;

public class NC61 {

    public int[] twoSum (int[] numbers, int target) {
        // write code here
        Arrays.sort(numbers);
        HashMap<Integer,Boolean> ans = new HashMap<>();
        for (int i = 0; i < numbers.length; i++) {
            ans.put(numbers[i],true);
        }
        int i=0;
        for (; i < numbers.length; i++) {
            if(target-numbers[i] <numbers[i]) return null;
            if(ans.get(target-numbers[i])!=null) break;
        }
        return new int[]{numbers[i],target-numbers[i]};
    }
}
